﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CUREDataAccessLayers;

using CUREEntity;


namespace CUREBusinessLogicLayer
{
    public class DeptBll
    {
        DeptDal deptdal = new DeptDal();

        /// <summary>
        /// 获取部门详细信息
        /// </summary>
        /// <returns></returns>
        public DataSet GetDeptData(IDictionary<string, object> where, int pageIndex, int pageSize, out int totalRecordCount, out int totalPageCount)
        {
            //IList<DeptEntity> list = null;
            DataSet ds = new DataSet();
            try
            {
                ds = deptdal.GetDeptData(where, pageIndex, pageSize, out totalRecordCount, out totalPageCount);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            return ds;
        }

        /// <summary>
        /// 根据id获取部门名称
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>部门名称</returns>
        public string GetDeptNameById(string id)
        {
            string name = string.Empty;
            try
            {
                name = deptdal.GeDeptNameById(id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            return name;
        }

        /// <summary>
        /// 新增部门信息
        /// </summary>
        /// <param name="where">参数</param>
        /// <returns>true 删除成功/fasle 删除失败</returns>
        public bool InsertDeptData(IDictionary<string, object> where)
        {
            bool result = false;
            try
            {
                result = deptdal.InsertDeptData(where);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            return result;
        }

        /// <summary>
        /// 修改部门信息
        /// </summary>
        /// <param name="where">参数</param>
        /// <returns>true 删除成功/fasle 删除失败</returns>
        public bool UpdateDeptData(IDictionary<string, object> where)
        {
            bool result = false;
            try
            {
                result = deptdal.UpdateDeptData(where);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }

        /// <summary>
        /// 删除部门信息
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>true 删除成功/fasle 删除失败</returns>
        public bool DeleteDeptData(string deptid)
        {
            bool result = false;
            try
            {
                result = deptdal.DeleteDeptData(deptid);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
    }
}
